<?php 

include '../utils/stock.php';
include '../utils/evaluator.php';
require('../utils/fpdf17/fpdf.php');
session_start() ;
?>
<html>
<head>
<script>
function open_win()
{
window.open("graph.php")
}
</script>
<style type="text/css">
body
{

font-family:"Calibri";}
}
</style>
</head>
<body>

<b>Recalculating INTRINSIC VALUE </b>
<br>

<br>


<?php


$stock = new stock;
$stock->get_stock_quote($_SESSION['evaluator']->ticker);

$_SESSION['evaluator']->average_growth_modified = $_POST['avgro'];
$i = $_SESSION['evaluator']->average_growth_modified;
$l = $_SESSION['evaluator']->federal_note;
$n = 10;
$fbv = $_SESSION['evaluator']->getFBVp($_SESSION['evaluator']->bookvalue2012, $i);
$div = $_SESSION['evaluator']->anualised_dividend;
$iv = $div*((1-(1/(pow((1+$l),10))))/$l) +$fbv/(pow((1+$l),10));
$p = $stock->last;





echo "<b>INTRINSIC VALUE: </b>";

echo  "".addColor($iv, $p)."";

echo "<br>";
echo "<i>Mod. BV growth: </i>";
echo  $_SESSION['evaluator']->average_growth_modified;




function addColor($number, $reference){
	if($number >= $reference) 
	{
		$res = "<b><font color='green'>". $number . "</font></b>";
	}
	else 
	{
		$res = "<font color='red'>". $number . "</font>";
	}
	
	return $res;
}

?>
<br />
<br />
If you want to recalculate, adjust growth below:
<br />
<form action="step6.php" method="post">
Average 10y growth: <input type="text" name="avgro"  />
<br />
<input type="submit" value="Recalculate"/>
</form>
<br />

<br />
<br />
<button type="button" onclick="location.href='step5.php'">Back</button>
<input type="button" value="Finish" onclick="open_win()" />



</body>
</html> 